﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using SalesSys.BLL;
using SalesSys.WebCore;

namespace SalesSys.Site.Controllers.Api
{
     [RoutePrefix("api/Admin")]
    public class AdminController : BaseApiController
    {
        // GET: api/Admin
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET: api/Admin/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Admin
        public void Post([FromBody]string value)
        {
        }

        [Route("ResetPwd")]
        public void PutResetPwd(Guid id)
        {
            EmployeeBLL bll = BllFactory.GetBll<EmployeeBLL>();

            var user = bll.Details(id);
            user.LoginPwd = SiteConfig.ConfigInfo.EmployeeDefPwd;
            bll.Edit(user);
        }
         [Route("SetRoles")]
         public void PutSetRoles(Guid id,string[] roles)
         {
             EmployeeBLL bll = BllFactory.GetBll<EmployeeBLL>();

             var user = bll.Details(id);
             user.Roles = string.Join("|",roles);
             bll.Edit(user);
         }

         // PUT: api/Admin/5
        public void Put(int id, [FromBody]string value)
        {
 
        }

        // DELETE: api/Admin/5
        public void Delete(int id)
        {
        }
    }
}
